package com.itany.hotel.action;

import com.itany.hotel.entity.Category;
import com.itany.hotel.service.RoomService;
import framework.bean.factory.ObjectFactory;
import framework.mvc.annotation.Action;
import framework.mvc.annotation.Controller;
import framework.mvc.annotation.Result;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
@Action(path = "/room")
public class RoomAction {

    @Action(path = "/findCategories",results = {
            @Result(name = "success",path = "/WEB-INF/page/roomPrice.jsp")
    })
    public String findCategories(HttpServletRequest request, HttpServletResponse response) throws ServletException {

        RoomService roomService= (RoomService) ObjectFactory.getObject("roomService");

        List<Category> categories=roomService.findCategories();

        request.setAttribute("categories",categories);

        return "success";
    }
}